<template>
  <div class="emergency">
    <el-dialog
      :visible.sync="showDialog"
      width="100%"
      top="0"
      :close-on-click-modal="false"
      :lock-scroll="true"
      @close="close"
    >
      <div slot="title">
        <h4>{{form.id ? '编辑紧急联系人' : '添加紧急联系人'}}</h4>
        <small class="text-muted">请不要和家庭成员重复</small>
      </div>
      <el-form ref="form" :model="form" :rules="rules" :inline="true">
        <el-form-item label="联系人姓名" prop="name">
          <el-input placeholder="请输入" v-model="form.name"></el-input>
        </el-form-item>
        <el-form-item label="关系" prop="relationship">
          <el-input placeholder="请输入" v-model="form.relationship"></el-input>
        </el-form-item>
        <el-form-item label="电话" prop="phone">
          <el-input placeholder="请输入" v-model="form.phone"></el-input>
        </el-form-item>
        <el-form-item label="联系地址" prop="address">
          <el-input placeholder="请输入" v-model="form.address"></el-input>
        </el-form-item>
        <el-form-item label="是否为主要联系人" prop="is_primary_contact">
          <el-select v-model="form.is_primary_contact">
            <el-option
              v-for="item in yesOrNoList"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            ></el-option>
          </el-select>
        </el-form-item>

        <el-button style="width: 100%" type="success" @click="finished">保存</el-button>
        <el-button v-if="row.id" style="width: 100%" type="default" @click="del">删除</el-button>
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
import common from '../mixins/common'

export default {
  name: 'Emergency',
  props: ['isVisible', 'row'],
  mixins: [common],
  data () {
    return {
      uuid: '',
      showDialog: false,
      form: {},
      rules: {},
      educationList: [],
      yesOrNoList: [
        { label: '是', value: 1 },
        { label: '否', value: 0 }
      ],
      editUrl: '/home/Emergency/save',
      delUrl: '/home/Emergency/del'
    }
  }
}
</script>
